using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;

namespace Data_Access_Tier
{
	public class HRM_INSURANCEData : DatabaseObjectBase
	{
		public HRM_INSURANCEData()
		{
			Initialize(true);
		}
		public HRM_INSURANCEData(Boolean newConnection)
		{
			Initialize(newConnection);
		}

		public Int32 HRM_INSURANCE_Insert(Guid InsuranceID, Guid InsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, String HealthInsuranceCode, DateTime Birthday, Boolean Sex, String IDCard, String MainAddress, String Province, String Hospital, Decimal OldSalary, Decimal OldAllowance1, Decimal OldAllowance2, Decimal OldAllowance3, Decimal OldAllowance4, Decimal NewSalary, Decimal NewAllowance1, Decimal NewAllowance2, Decimal NewAllowance3, Decimal NewAllowance4, DateTime FromDate, DateTime ToDate, Double Rate, Boolean IsPay, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.InsertCommand = new SqlCommand("HRM_INSURANCE_Insert");
				_dbadapter.InsertCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.InsertCommand.Connection = _dbconn;
				_trans = _dbconn.BeginTransaction();
				_dbadapter.InsertCommand.Transaction = _trans;
				_dbadapter.InsertCommand.Parameters.Clear();
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@HealthInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Province", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Hospital", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@OldSalary", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@OldAllowance1", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@OldAllowance2", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@OldAllowance3", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@OldAllowance4", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@NewSalary", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@NewAllowance1", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@NewAllowance2", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@NewAllowance3", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@NewAllowance4", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@FromDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@ToDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Rate", SqlDbType.Float));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@IsPay", SqlDbType.Bit));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.InsertCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
				_dbadapter.InsertCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.InsertCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.InsertCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.InsertCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlString HealthInsuranceCodeSQL = HealthInsuranceCode;
				_dbadapter.InsertCommand.Parameters["@HealthInsuranceCode"].Value = HealthInsuranceCodeSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.InsertCommand.Parameters["@Sex"].Value = SexSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.InsertCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.InsertCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ProvinceSQL = Province;
				_dbadapter.InsertCommand.Parameters["@Province"].Value = ProvinceSQL;
				SqlString HospitalSQL = Hospital;
				_dbadapter.InsertCommand.Parameters["@Hospital"].Value = HospitalSQL;
				SqlMoney OldSalarySQL = OldSalary;
				_dbadapter.InsertCommand.Parameters["@OldSalary"].Value = OldSalarySQL;
				SqlMoney OldAllowance1SQL = OldAllowance1;
				_dbadapter.InsertCommand.Parameters["@OldAllowance1"].Value = OldAllowance1SQL;
				SqlMoney OldAllowance2SQL = OldAllowance2;
				_dbadapter.InsertCommand.Parameters["@OldAllowance2"].Value = OldAllowance2SQL;
				SqlMoney OldAllowance3SQL = OldAllowance3;
				_dbadapter.InsertCommand.Parameters["@OldAllowance3"].Value = OldAllowance3SQL;
				SqlMoney OldAllowance4SQL = OldAllowance4;
				_dbadapter.InsertCommand.Parameters["@OldAllowance4"].Value = OldAllowance4SQL;
				SqlMoney NewSalarySQL = NewSalary;
				_dbadapter.InsertCommand.Parameters["@NewSalary"].Value = NewSalarySQL;
				SqlMoney NewAllowance1SQL = NewAllowance1;
				_dbadapter.InsertCommand.Parameters["@NewAllowance1"].Value = NewAllowance1SQL;
				SqlMoney NewAllowance2SQL = NewAllowance2;
				_dbadapter.InsertCommand.Parameters["@NewAllowance2"].Value = NewAllowance2SQL;
				SqlMoney NewAllowance3SQL = NewAllowance3;
				_dbadapter.InsertCommand.Parameters["@NewAllowance3"].Value = NewAllowance3SQL;
				SqlMoney NewAllowance4SQL = NewAllowance4;
				_dbadapter.InsertCommand.Parameters["@NewAllowance4"].Value = NewAllowance4SQL;
				SqlDateTime FromDateSQL = SqlDateTime.Null;
				if (FromDate > DateTime.MinValue)
				{
					try
					{
						FromDateSQL = FromDate;
					}
					catch (Exception eFromDate)
					{
						String FromDateMessage = eFromDate.Message;
						FromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@FromDate"].Value = FromDateSQL;
				SqlDateTime ToDateSQL = SqlDateTime.Null;
				if (ToDate > DateTime.MinValue)
				{
					try
					{
						ToDateSQL = ToDate;
					}
					catch (Exception eToDate)
					{
						String ToDateMessage = eToDate.Message;
						ToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@ToDate"].Value = ToDateSQL;
				SqlDouble RateSQL = Rate;
				_dbadapter.InsertCommand.Parameters["@Rate"].Value = RateSQL;
				SqlBoolean IsPaySQL = IsPay;
				_dbadapter.InsertCommand.Parameters["@IsPay"].Value = IsPaySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.InsertCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.InsertCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.InsertCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_INSURANCE_Insert: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_INSURANCE_Insert: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.InsertCommand != null)
					_dbadapter.InsertCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_INSURANCE_Update(Guid InsuranceID, Guid InsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, String HealthInsuranceCode, DateTime Birthday, Boolean Sex, String IDCard, String MainAddress, String Province, String Hospital, Decimal OldSalary, Decimal OldAllowance1, Decimal OldAllowance2, Decimal OldAllowance3, Decimal OldAllowance4, Decimal NewSalary, Decimal NewAllowance1, Decimal NewAllowance2, Decimal NewAllowance3, Decimal NewAllowance4, DateTime FromDate, DateTime ToDate, Double Rate, Boolean IsPay, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_INSURANCE_Update");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@HealthInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Province", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Hospital", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@FromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Rate", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsPay", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.UpdateCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
				_dbadapter.UpdateCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.UpdateCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlString HealthInsuranceCodeSQL = HealthInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@HealthInsuranceCode"].Value = HealthInsuranceCodeSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.UpdateCommand.Parameters["@Sex"].Value = SexSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.UpdateCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.UpdateCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ProvinceSQL = Province;
				_dbadapter.UpdateCommand.Parameters["@Province"].Value = ProvinceSQL;
				SqlString HospitalSQL = Hospital;
				_dbadapter.UpdateCommand.Parameters["@Hospital"].Value = HospitalSQL;
				SqlMoney OldSalarySQL = OldSalary;
				_dbadapter.UpdateCommand.Parameters["@OldSalary"].Value = OldSalarySQL;
				SqlMoney OldAllowance1SQL = OldAllowance1;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance1"].Value = OldAllowance1SQL;
				SqlMoney OldAllowance2SQL = OldAllowance2;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance2"].Value = OldAllowance2SQL;
				SqlMoney OldAllowance3SQL = OldAllowance3;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance3"].Value = OldAllowance3SQL;
				SqlMoney OldAllowance4SQL = OldAllowance4;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance4"].Value = OldAllowance4SQL;
				SqlMoney NewSalarySQL = NewSalary;
				_dbadapter.UpdateCommand.Parameters["@NewSalary"].Value = NewSalarySQL;
				SqlMoney NewAllowance1SQL = NewAllowance1;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance1"].Value = NewAllowance1SQL;
				SqlMoney NewAllowance2SQL = NewAllowance2;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance2"].Value = NewAllowance2SQL;
				SqlMoney NewAllowance3SQL = NewAllowance3;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance3"].Value = NewAllowance3SQL;
				SqlMoney NewAllowance4SQL = NewAllowance4;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance4"].Value = NewAllowance4SQL;
				SqlDateTime FromDateSQL = SqlDateTime.Null;
				if (FromDate > DateTime.MinValue)
				{
					try
					{
						FromDateSQL = FromDate;
					}
					catch (Exception eFromDate)
					{
						String FromDateMessage = eFromDate.Message;
						FromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@FromDate"].Value = FromDateSQL;
				SqlDateTime ToDateSQL = SqlDateTime.Null;
				if (ToDate > DateTime.MinValue)
				{
					try
					{
						ToDateSQL = ToDate;
					}
					catch (Exception eToDate)
					{
						String ToDateMessage = eToDate.Message;
						ToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@ToDate"].Value = ToDateSQL;
				SqlDouble RateSQL = Rate;
				_dbadapter.UpdateCommand.Parameters["@Rate"].Value = RateSQL;
				SqlBoolean IsPaySQL = IsPay;
				_dbadapter.UpdateCommand.Parameters["@IsPay"].Value = IsPaySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.UpdateCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_INSURANCE_Update: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_INSURANCE_Update: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_INSURANCE_Disable(Guid InsuranceID, ref Boolean Enabled)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_INSURANCE_Disable");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@enabled", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.UpdateCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				_dbadapter.UpdateCommand.Parameters["@enabled"].Direction = ParameterDirection.Output;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_INSURANCE_Disable: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_INSURANCE_Disable: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_INSURANCE_Delete(Guid InsuranceID)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.DeleteCommand = new SqlCommand("HRM_INSURANCE_Delete");
				_dbadapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.DeleteCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.DeleteCommand.Transaction = _trans;

				_dbadapter.DeleteCommand.Parameters.Clear();
				_dbadapter.DeleteCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.DeleteCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.DeleteCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.DeleteCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_INSURANCE_Delete: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_INSURANCE_Delete: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.DeleteCommand != null)
					_dbadapter.DeleteCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_INSURANCE_Save(Guid InsuranceID, Guid InsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, String HealthInsuranceCode, DateTime Birthday, Boolean Sex, String IDCard, String MainAddress, String Province, String Hospital, Decimal OldSalary, Decimal OldAllowance1, Decimal OldAllowance2, Decimal OldAllowance3, Decimal OldAllowance4, Decimal NewSalary, Decimal NewAllowance1, Decimal NewAllowance2, Decimal NewAllowance3, Decimal NewAllowance4, DateTime FromDate, DateTime ToDate, Double Rate, Boolean IsPay, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_INSURANCE_Save");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@HealthInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Province", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Hospital", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@OldAllowance4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@NewAllowance4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@FromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Rate", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsPay", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.UpdateCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
				_dbadapter.UpdateCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.UpdateCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlString HealthInsuranceCodeSQL = HealthInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@HealthInsuranceCode"].Value = HealthInsuranceCodeSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.UpdateCommand.Parameters["@Sex"].Value = SexSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.UpdateCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.UpdateCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ProvinceSQL = Province;
				_dbadapter.UpdateCommand.Parameters["@Province"].Value = ProvinceSQL;
				SqlString HospitalSQL = Hospital;
				_dbadapter.UpdateCommand.Parameters["@Hospital"].Value = HospitalSQL;
				SqlMoney OldSalarySQL = OldSalary;
				_dbadapter.UpdateCommand.Parameters["@OldSalary"].Value = OldSalarySQL;
				SqlMoney OldAllowance1SQL = OldAllowance1;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance1"].Value = OldAllowance1SQL;
				SqlMoney OldAllowance2SQL = OldAllowance2;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance2"].Value = OldAllowance2SQL;
				SqlMoney OldAllowance3SQL = OldAllowance3;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance3"].Value = OldAllowance3SQL;
				SqlMoney OldAllowance4SQL = OldAllowance4;
				_dbadapter.UpdateCommand.Parameters["@OldAllowance4"].Value = OldAllowance4SQL;
				SqlMoney NewSalarySQL = NewSalary;
				_dbadapter.UpdateCommand.Parameters["@NewSalary"].Value = NewSalarySQL;
				SqlMoney NewAllowance1SQL = NewAllowance1;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance1"].Value = NewAllowance1SQL;
				SqlMoney NewAllowance2SQL = NewAllowance2;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance2"].Value = NewAllowance2SQL;
				SqlMoney NewAllowance3SQL = NewAllowance3;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance3"].Value = NewAllowance3SQL;
				SqlMoney NewAllowance4SQL = NewAllowance4;
				_dbadapter.UpdateCommand.Parameters["@NewAllowance4"].Value = NewAllowance4SQL;
				SqlDateTime FromDateSQL = SqlDateTime.Null;
				if (FromDate > DateTime.MinValue)
				{
					try
					{
						FromDateSQL = FromDate;
					}
					catch (Exception eFromDate)
					{
						String FromDateMessage = eFromDate.Message;
						FromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@FromDate"].Value = FromDateSQL;
				SqlDateTime ToDateSQL = SqlDateTime.Null;
				if (ToDate > DateTime.MinValue)
				{
					try
					{
						ToDateSQL = ToDate;
					}
					catch (Exception eToDate)
					{
						String ToDateMessage = eToDate.Message;
						ToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@ToDate"].Value = ToDateSQL;
				SqlDouble RateSQL = Rate;
				_dbadapter.UpdateCommand.Parameters["@Rate"].Value = RateSQL;
				SqlBoolean IsPaySQL = IsPay;
				_dbadapter.UpdateCommand.Parameters["@IsPay"].Value = IsPaySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.UpdateCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_INSURANCE_Save: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_INSURANCE_Save: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_INSURANCE_GetList()
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetList");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Prepare();
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_INSURANCE_GetList: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_INSURANCE_Get(Guid InsuranceID)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_Get");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceID", SqlDbType.UniqueIdentifier));
				_dbadapter.SelectCommand.Prepare();
				SqlGuid InsuranceIDSQL = InsuranceID;
				_dbadapter.SelectCommand.Parameters["@InsuranceID"].Value = InsuranceIDSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_INSURANCE_Get: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}

        public DataSet HRM_INSURANCE_Get02aTBHTotalUp(Int32 NumberSocial,Int32 NumberHealth,Decimal WageSocial,Decimal WageHealth,Decimal PaySocial,Decimal PayHealth,Decimal PayExtraSocial,Decimal PayExtraHealth,Int32 ExtraMonth)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_Get02aTBHTotalUp");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PaySocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@ExtraMonth", SqlDbType.Int));
                _dbadapter.SelectCommand.Prepare();
                SqlInt32 NumberSocialSQL = NumberSocial;
                SqlInt32 NumberHealthSQL = NumberHealth;
                SqlMoney WageSocialSQL = WageSocial;
                SqlMoney WageHealthSQL = WageHealth;
                SqlMoney PaySocialSQL = PaySocial;
                SqlMoney PayHealthSQL = PayHealth;
                SqlMoney PayExtraSocialSQL = PayExtraSocial;
                SqlMoney PayExtraHealthSQL = PayExtraHealth;
                SqlInt32 ExtraMonthSQL = ExtraMonth;
                _dbadapter.SelectCommand.Parameters["@NumberSocial"].Value = NumberSocialSQL;
                _dbadapter.SelectCommand.Parameters["@NumberHealth"].Value = NumberHealthSQL;
                _dbadapter.SelectCommand.Parameters["@WageSocial"].Value = WageSocialSQL;
                _dbadapter.SelectCommand.Parameters["@WageHealth"].Value = WageHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PaySocial"].Value = PaySocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayHealth"].Value = PayHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraSocial"].Value = PayExtraSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraHealth"].Value = PayExtraHealthSQL;
                _dbadapter.SelectCommand.Parameters["@ExtraMonth"].Value = ExtraMonthSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_Get02aTBHTotalUp: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_Get03aTBHTotalUp(Int32 NumberIncreaseSocial,Int32 NumberDecreaseSocial,Int32 NumberIncreaseHealth,Int32 NumberDecreaseHealth,Int32 NumberIncreaseUnemployment,Int32 NumberDecreaseUnemployment,Decimal WageIncreaseSocial,
            Decimal WageDecreaseSocial,Decimal WageIncreaseHealth, Decimal WageDecreaseHealth,Decimal WageIncreaseUnemployment,
            Decimal WageDecreaseUnemployment, Decimal PayIncreaseSocial, Decimal PayDecreaseSocial,Decimal PayIncreaseHealth,Decimal PayDecreaseHealth,
            Decimal PayIncreaseUnemployment,
            Decimal PayDecreaseUnemployment,
            Decimal PayExtraIncreaseSocial,
            Decimal PayExtraDecreaseSocial,
            Decimal PayExtraIncreaseHealth,
            Decimal PayExtraDecreaseHealth,
            Decimal PayExtraIncreaseUnemployment,
            Decimal PayExtraDecreaseUnemployment,
            Int32 ExtraMonth,
            Int32 NumberOldSocial,
            Int32 NumberNewSocial,
            Int32 NumberOldHealth,
            Int32 NumberNewHealth,
            Int32 NumberOldUnemployment,
            Int32 NumberNewUnemployment,
            Int32 WageOldSocial,
            Int32 WageNewSocial,
            Int32 WageOldHealth,
            Int32 WageNewHealth,
            Int32 WageOldUnemployment,
            Int32 WageNewUnemployment,
            Int32 PayOldSocial,
            Int32 PayNewSocial,
            Int32 PayOldHealth,
            Int32 PayNewHealth,
            Int32 PayOldUnemployment,
            Int32 PayNewUnemployment)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_Get03aTBHTotalUp");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberIncreaseSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberDecreaseSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberIncreaseHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberDecreaseHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberIncreaseUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberDecreaseUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageIncreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageDecreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageIncreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageDecreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageIncreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageDecreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayIncreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayDecreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayIncreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayDecreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayIncreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayDecreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraIncreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraDecreaseSocial", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraIncreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraDecreaseHealth", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraIncreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayExtraDecreaseUnemployment", SqlDbType.Money));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@ExtraMonth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberOldSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberNewSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberOldHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberNewHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberOldUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@NumberNewUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageOldSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageNewSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageOldHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageNewHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageOldUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WageNewUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayOldSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayNewSocial", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayOldHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayNewHealth", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayOldUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@PayNewUnemployment", SqlDbType.Int));
                _dbadapter.SelectCommand.Prepare();
                SqlInt32 NumberIncreaseSocialSQL = NumberIncreaseSocial;
                SqlInt32 NumberDecreaseSocialSQL = NumberDecreaseSocial;
                SqlInt32 NumberIncreaseHealthSQL = NumberIncreaseHealth;
                SqlInt32 NumberDecreaseHealthSQL = NumberDecreaseHealth;
                SqlInt32 NumberIncreaseUnemploymentSQL = NumberIncreaseUnemployment;
                SqlInt32 NumberDecreaseUnemploymentSQL = NumberDecreaseUnemployment;
                SqlMoney WageIncreaseSocialSQL = WageIncreaseSocial;
                SqlMoney WageDecreaseSocialSQL = WageDecreaseSocial;
                SqlMoney WageIncreaseHealthSQL = WageIncreaseHealth;
                SqlMoney WageDecreaseHealthSQL = WageDecreaseHealth;
                SqlMoney WageIncreaseUnemploymentSQL = WageIncreaseUnemployment;
                SqlMoney WageDecreaseUnemploymentSQL = WageDecreaseUnemployment;
                SqlMoney PayIncreaseSocialSQL = PayIncreaseSocial;
                SqlMoney PayDecreaseSocialSQL = PayDecreaseSocial;
                SqlMoney PayIncreaseHealthSQL = PayIncreaseHealth;
                SqlMoney PayDecreaseHealthSQL = PayDecreaseHealth;
                SqlMoney PayIncreaseUnemploymentSQL = PayIncreaseUnemployment;
                SqlMoney PayDecreaseUnemploymentSQL = PayDecreaseUnemployment;
                SqlMoney PayExtraIncreaseSocialSQL = PayExtraIncreaseSocial;
                SqlMoney PayExtraDecreaseSocialSQL = PayExtraDecreaseSocial;
                SqlMoney PayExtraIncreaseHealthSQL = PayExtraIncreaseHealth;
                SqlMoney PayExtraDecreaseHealthSQL = PayExtraDecreaseHealth;
                SqlMoney PayExtraIncreaseUnemploymentSQL = PayExtraIncreaseUnemployment;
                SqlMoney PayExtraDecreaseUnemploymentSQL = PayExtraDecreaseUnemployment;
                SqlInt32 ExtraMonthSQL = ExtraMonth;
                SqlInt32 NumberOldSocialSQL = NumberOldSocial;
                SqlInt32 NumberNewSocialSQL = NumberNewSocial;
                SqlInt32 NumberOldHealthSQL = NumberOldHealth;
                SqlInt32 NumberNewHealthSQL = NumberNewHealth;
                SqlInt32 NumberOldUnemploymentSQL = NumberOldUnemployment;
                SqlInt32 NumberNewUnemploymentSQL = NumberNewUnemployment;
                SqlInt32 WageOldSocialSQL = WageOldSocial;
                SqlInt32 WageNewSocialSQL = WageNewSocial;
                SqlInt32 WageOldHealthSQL = WageOldHealth;
                SqlInt32 WageNewHealthSQL = WageNewHealth;
                SqlInt32 WageOldUnemploymentSQL = WageOldUnemployment;
                SqlInt32 WageNewUnemploymentSQL = WageNewUnemployment;
                SqlInt32 PayOldSocialSQL = PayOldSocial;
                SqlInt32 PayNewSocialSQL = PayNewSocial;
                SqlInt32 PayOldHealthSQL = PayOldHealth;
                SqlInt32 PayNewHealthSQL = PayNewHealth;
                SqlInt32 PayOldUnemploymentSQL = PayOldUnemployment;
                SqlInt32 PayNewUnemploymentSQL = PayNewUnemployment;
                _dbadapter.SelectCommand.Parameters["@NumberIncreaseSocial"].Value = NumberIncreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@NumberDecreaseSocial"].Value = NumberDecreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@NumberIncreaseHealth"].Value = NumberIncreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@NumberDecreaseHealth"].Value = NumberDecreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@NumberIncreaseUnemployment"].Value = NumberIncreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@NumberDecreaseUnemployment"].Value = NumberDecreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@WageIncreaseSocial"].Value = WageIncreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@WageDecreaseSocial"].Value = WageDecreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@WageIncreaseHealth"].Value = WageIncreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@WageDecreaseHealth"].Value = WageDecreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@WageIncreaseUnemployment"].Value = WageIncreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@WageDecreaseUnemployment"].Value = WageDecreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayIncreaseSocial"].Value = PayIncreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayDecreaseSocial"].Value = PayDecreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayIncreaseHealth"].Value = PayIncreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayDecreaseHealth"].Value = PayDecreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayIncreaseUnemployment"].Value = PayIncreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayDecreaseUnemployment"].Value = PayDecreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraIncreaseSocial"].Value = PayExtraIncreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraDecreaseSocial"].Value = PayExtraDecreaseSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraIncreaseHealth"].Value = PayExtraIncreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraDecreaseHealth"].Value = PayExtraDecreaseHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraIncreaseUnemployment"].Value = PayExtraIncreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayExtraDecreaseUnemployment"].Value = PayExtraDecreaseUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@ExtraMonth"].Value = ExtraMonthSQL;
                _dbadapter.SelectCommand.Parameters["@NumberOldSocial"].Value = NumberOldSocialSQL;
                _dbadapter.SelectCommand.Parameters["@NumberNewSocial"].Value = NumberNewSocialSQL;
                _dbadapter.SelectCommand.Parameters["@NumberOldHealth"].Value = NumberOldHealthSQL;
                _dbadapter.SelectCommand.Parameters["@NumberNewHealth"].Value = NumberNewHealthSQL;
                _dbadapter.SelectCommand.Parameters["@NumberOldUnemployment"].Value = NumberOldUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@NumberNewUnemployment"].Value = NumberNewUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@WageOldSocial"].Value = WageOldSocialSQL;
                _dbadapter.SelectCommand.Parameters["@WageNewSocial"].Value = WageNewSocialSQL;
                _dbadapter.SelectCommand.Parameters["@WageOldHealth"].Value = WageOldHealthSQL;
                _dbadapter.SelectCommand.Parameters["@WageNewHealth"].Value = WageNewHealthSQL;
                _dbadapter.SelectCommand.Parameters["@WageOldUnemployment"].Value = WageOldUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@WageNewUnemployment"].Value = WageNewUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayOldSocial"].Value = PayOldSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayNewSocial"].Value = PayNewSocialSQL;
                _dbadapter.SelectCommand.Parameters["@PayOldHealth"].Value = PayOldHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayNewHealth"].Value = PayNewHealthSQL;
                _dbadapter.SelectCommand.Parameters["@PayOldUnemployment"].Value = PayOldUnemploymentSQL;
                _dbadapter.SelectCommand.Parameters["@PayNewUnemployment"].Value = PayNewUnemploymentSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_Get03aTBHTotalUp: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetList03aTBH(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetList03aTBH");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetList03aTBH: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListAddHealth(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListAddHealth");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListAddHealth: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListAddUnemployment(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListAddUnemployment");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListAddUnemployment: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListByInsuranceTableList(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListByInsuranceTableList");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListByInsuranceTableList: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListByType(Guid InsuranceTableListID,Int32 Type)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListByType");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                SqlInt32 TypeSQL = Type;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.SelectCommand.Parameters["@Type"].Value = TypeSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListByType: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListChangeSalary(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListChangeSalary");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListChangeSalary: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListDecrease(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListDecrease");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListDecrease: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListIncrease(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListIncrease");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListIncrease: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListModify(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListModify");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListModify: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_GetListType(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_GetListType");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_GetListType: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }

        public DataSet HRM_INSURANCE_TABLELIST_Delete(Guid InsuranceTableListID)
        {
            try
            {
                if (_dbconn.State != ConnectionState.Open)
                    _dbconn.Open();
                _dbadapter.SelectCommand = new SqlCommand("HRM_INSURANCE_TABLELIST_Delete");
                _dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                _dbadapter.SelectCommand.Connection = _dbconn;
                _dbadapter.SelectCommand.Parameters.Clear();
                _dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@InsuranceTableListID", SqlDbType.UniqueIdentifier));
                _dbadapter.SelectCommand.Prepare();
                SqlGuid InsuranceTableListIDSQL = InsuranceTableListID;
                _dbadapter.SelectCommand.Parameters["@InsuranceTableListID"].Value = InsuranceTableListIDSQL;
                _dbadapter.Fill(_data);

                return _data;
            }
            catch (SqlException e)
            {
                throw new Exception("SQL Error: HRM_INSURANCE_TABLELIST_Delete: " + e.Message, e);
            }
            finally
            {
                if (_dbadapter.SelectCommand != null)
                    _dbadapter.SelectCommand.Dispose();
                CloseConnection();
            }
        }
    }
}
